package com.dmxtechnologies.community.rar;

import java.util.logging.Logger;

import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ConfigProperty;
import javax.resource.spi.Connector;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterInternalException;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;

@Connector(
        displayName = "DMX CMS ResourceAdapter",
        vendorName = "DMX", 
        version = "1.0"
)
public class DMXCMSResourceAdapter implements ResourceAdapter {
   
    private static final Logger log = Logger.getLogger("DMXCMSResourceAdapter");
    /* Configuration properties */
	@ConfigProperty(defaultValue = "localhost")
    private String host;
	@ConfigProperty(type = Integer.class, defaultValue = "80")
    private Integer port;
   	@ConfigProperty(defaultValue = "cms-portal")
    private String projectName;
   	@ConfigProperty(defaultValue = "dataEnginerServlet")
   	private String interfaceName;
    
    public String getInterfaceName() {
		return interfaceName;
	}

	public void setInterfaceName(String interfaceName) {
		this.interfaceName = interfaceName;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	@Override
    public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
        log.info("[DMXCMSResourceAdapter] start()");
    }

    @Override
    public void stop() {
        log.info("[DMXCMSResourceAdapter] stop()");
    }

    /* These are called for inbound connectors */
    @Override
    public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException {
        log.info("[TradeResourceAdapter] endpointActivation()");
    }
    @Override
    public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
        log.info("[TradeResourceAdapter] endpointDeactivation()");
    }

    /* This connector does not use transactions */
    @Override
    public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
        return null;
    }
    
}
